package message

import "gm/config"

const (
	// EmailType type
	EmailType = "email"
	// SMSType type
	SMSType = "sms"
)

var (
	from     string
	smtp     string
	username string
	password string
	port     int
)

func init() {
	cfg := config.Cfg
	emailSec := "email"
	var err error

	if from, err = cfg.GetValue(emailSec, "from"); err != nil {
		panic(err)
	}

	if smtp, err = cfg.GetValue(emailSec, "smtp"); err != nil {
		panic(err)
	}

	if username, err = cfg.GetValue(emailSec, "username"); err != nil {
		panic(err)
	}

	if password, err = cfg.GetValue(emailSec, "password"); err != nil {
		panic(err)
	}

	port = cfg.MustInt(emailSec, "port", 465)
}

//Message interface
type Message interface {
	Send(subject string, content string, users string, attachFilePath []string, attachFileName []string, late int64, sendInOne bool)
}
